#include<bits/stdc++.h>
using namespace std;
#define int long long
int t;
int n,m,l,V;
struct stu{
    int d,v,a;
}node[100010];
int p[100010],p2[100010];
int f2(int i){
    int l=1,r=m;
    while(l<r){
        int mid=(l+r)>>1;
        if(p[mid]>=node[i].d){
            r=mid;
        }
        else l=mid+1;
    }
    return l;
}
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>t;
    while(t--){
        cin>>n>>m>>l>>V;
        for(int i=1;i<=n;i++){
            cin>>node[i].d>>node[i].v>>node[i].a;
        }
        for(int i=1;i<=m;i++){
            cin>>p[i];
        }
        if(node[1].a==0){
            int cnt=0;
            for(int i=1;i<=n;i++){
                if(node[i].v<=V||node[i].d>p[m]) continue;
                //int tmp=f2(i);
                cnt++;
            }
            cout<<cnt<<' ';
            if(cnt==0) cout<<m;
            else cout<<m-1;
            cout<<'\n';
        }
        else{
            int cnt=0;
            for(int i=1;i<=n;i++){
                if(node[i].d>p[m]) continue;
                if(node[i].d==p[m]&&node[i].v<=V) continue;
                if(2*node[i].a*abs(node[i].d-p[m])>V*V){
                    cnt++;
                }
            }
            cout<<cnt<<' ';
            if(cnt==0) cout<<m;
            else cout<<m-1;
            cout<<'\n';
        }
    }
    return 0;
}
